const service = require('/mineService.js');
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    moneyNum:null,
    userInfo: {},
    hasUserInfo: false,
    tkshNumBoolean: true,
    tkshNum: 0,
    dpjNumBoolean: true,
    dpjNum: 0,
    dshNumBoolean: true,
    dshNum: 0,
    dfkNumBoolean: true,
    dfkNum: 0,
    count:0,
    userSweets:0,
    walletIsOpen: false,
    userListInfo: [ {
        icon: '../../images/mine/icon-release.png',
        text: '我发布的',
        isunread: false,
        unreadNum: 1,
        bindtapStr: 'myReleaseTap'
      }, {
        icon: '../../images/mine/icon-participate.png',
        text: '参与的竞拍',
        isunread: false,
        unreadNum: 1,
        bindtapStr: 'myBiddersTap'
      }, {
        icon: '../../images/mine/icon-follow.png',
        text: '关注的人',
        bindtapStr: 'myFollowTap'
      }, {
        icon: '../../images/mine/icon-msg.png',
        text: '我的消息',
        bindtapStr: 'myMessageTap'
      }, {
        icon: '../../images/mine/icon-fabulous.png',
        text: '我的收藏',
        bindtapStr: 'myCollectionTap'
      }, {
        icon: '../../images/mine/icon-integral.png',
        text: '果冻兑换',
        bindtapStr: 'myIntegralTap'
      }, {
        icon: '../../images/mine/icon-contact.png',
        text: '联系客服',
        bindtapStr: 'myServiceTap'
      }
      , {
        icon: '../../images/mine/icon-settings.png',
        text: '设置',
        bindtapStr: 'settingsTap'
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log("onLoad")
    this.setData({
      userinfo: app.globalData.userInfo,
      count: this.data.userListInfo.length - 1,
      userSweets: app.globalData.userSweets,
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log("onShow")
    this.userOnLoad();
    this.requestMoneysData();
    this.setData({
      userinfo: app.globalData.userInfo,
      count: this.data.userListInfo.length - 1,
      userSweets: app.globalData.userSweets,
    })
  },
  onPullDownRefresh: function() {
    console.log('下拉')
    this.userOnLoad();
  },
  /**
   * 请求提现总金额
   */
  requestMoneysData: function(){
    var that = this
    var param = {
      
    }
    service.requestMoneys(param, function (data) {
      var array = data.items;
      that.setData({ moneyNum: data });
      });
  },
  /**
   * 请求个人信息
   */
  userOnLoad: function () {
    console.log(app.globalData);
    // 判断自己是否登录
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
      // this.getUserApiInfo();
    } else {
      // 去登录
    }
  },
  goWallet: function(e){
    wx.navigateTo({
      url: "/withdrawCash/pages/withdrawCash/withdrawCash" + "?title=" + "提现",
    })
  },
//点击了商家入驻
  myBusinessTap: function () {
    wx.navigateTo({
      url: './merchants/merchants',
    })
  },
  //点击了我发布的
  myReleaseTap: function () {
    
    wx.navigateTo({
      url: '/mineSubs/pages/homepage/personalhomepage',
    })
  },
//点击了参与的竞拍
  myBiddersTap: function () {
    wx.navigateTo({
      url: '/pages/mine/auction/auction'
    })
  },
//点击了个人主页
  seePersonalHome: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/homepage/personalhomepage'
,
    })
  },
//点击了关注的人
  myFollowTap: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/myFocus/myFocus',
    })
  },

  myMessageTap: function () {
    wx.switchTab({
      url: '/pages/mine/message/message',
    })
  },

  myCollectionTap: function () {
    wx.navigateTo({
      url: '/pages/mine/fav/fav'
    })
  },
//点击了积分兑换
  myIntegralTap: function () {
    wx.navigateTo({
      url: '/pages/mine/jifen/jifenGift',
    })
  },
//设置
  settingsTap: function(){
    wx.navigateTo({
      url: '/pages/mine/settings/settings',
    })
  },
  
//点击了查看全部
  seeAllMyBabyClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/giveBaby/giveBaby?type=1',
    })
  },
//点击了赠送中
  sendingClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/giveBaby/giveBaby?type=2',
    })
  },
//点击了待出发
  stayClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/giveBaby/giveBaby?type=3',
    })
  },
//点击了待收货
  stayGoodsClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/giveBaby/giveBaby?type=4',
    })
  },
//点击了收到感谢
  obtainThankClick: function () {
    
    wx.navigateTo({
      url: '/mineSubs/pages/thanksVideo/thanksVideo?type=2',
    })
  },
//点击了查看全部
  obtainBabyClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/getBaby/getBaby?type=1',
    })
  },
//点击了待付款
  stayMoneyClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/getBaby/getBaby?type=2',
    })
  },
//点击了待出发
  stayGotoClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/getBaby/getBaby?type=3',
    })
  },
 // 点击了收货
  stayObatinGoodsClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/getBaby/getBaby?type=4',
    })
  },
//点击了发出感谢
  giveThanksClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/thanksVideo/thanksVideo?type=1',
    })
  },
//点击了赚红花
  earnRedFloweClick: function () {
    wx.navigateTo({
      url: '/mineSubs/pages/getFlowers/getFlowers?type=1',
    })
  },
  /**
* 提交formid
*/
  submitForm: function (e) {
    // 获取表单id
    let formId = e.detail.formId;
    getApp().saveUserFormId(formId, 21);
  },
//修改地址
  changeAddressClick:function(e){
    wx.navigateTo({
      url: '../addProduct/myAddress/myAddres',
    })
  },
  levelClick: function(e) {
    wx.navigateTo({
      url: '/mineSubs/pages/level/level',
    })
  }
})